import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
 * Author: Daniel Michalski
 * Date: 14.03.13
 */

public class ScannerTest {
    public static void main(String[] args) throws IOException {
        final String fileName = "test.txt";

        FileWriter fout = new FileWriter(fileName);
        fout.write("Testowanie klasy Scanner 10 12,2 jeden true dwa false");
        fout.close();

        FileReader fin = new FileReader(fileName);

        try (Scanner scanner = new Scanner(fin)) {
            while (scanner.hasNext()) {
                if (scanner.hasNextInt()) {
                    int i = scanner.nextInt();
                    System.out.println("int: " + i);
                } else if (scanner.hasNextDouble()) {
                    double d = scanner.nextDouble();
                    System.out.println("double: " + d);
                } else if (scanner.hasNextBoolean()) {
                    boolean b = scanner.nextBoolean();
                    System.out.println("boolean: " + b);
                } else {
                    String str = scanner.next();
                    System.out.println("String: " + str);
                }
            }
        }

    }
}
